'''
Created on 2012-6-30

@author: wb_suoyao.shen
'''
from django.db import models

class AboutMeManager(models.Manager):
    def about_me(self):
        about_list = self.raw('SELECT id,name,email,play,resume FROM admin_aboutme ORDER BY name LIMIT 1')
        if len(list(about_list)) > 0:
            return about_list[0]
        else:
            return None

class AboutMe(models.Model):
    name = models.CharField(max_length=256, null=True, blank=True)
    password = models.CharField(max_length=256,null=False,blank=False)
    email = models.EmailField(max_length=2560, null=True, blank=True)
    play = models.TextField(null=True, blank=True)
    resume = models.TextField(null=True, blank=True)
    objects = AboutMeManager()
    
    def __unicode__(self):
        return self.name
    
    class Meta:
        ordering = ['name']
    
    class Admin:
        list_display = ('name','email','play','resume')
        fields = (
            (None,{'fields':('name','email','play','resume')}),
        )